# import subprocess
# import time
# import os
from AutoArchieve import *
from Networking import *

# 获取工程的项目路径
def getxcworkspacepath():
    path = input('请输入.workspace所在目录的绝对路径:')
    if len(path) == 0:
        print('* 我走过最长的路就是你的套路，输入错误，请重新输入 *')
        getxcworkspacepath()
    else:
        print('.workspace文件路径为：'+path)
        return path


def getProjectName():
    name = input('请输入工程名称：')
    if len(name) == 0:
        print('* 我走过最长的路就是你的套路，输入错误，请重新输入 *')
        getProjectName()
    else:
        print('工程名称为：'+name)
        return name


if __name__ == '__main__':
    autoScript = AutoArchieveClass()
    projectPath = getxcworkspacepath()
    projectName = getProjectName()
    apiKey = input('请输入蒲公英项目apiKey')
    # 从git上拉取代码
    autoScript.updateProjectFromGitWith(projectPath)
    # pods更新
    autoScript.updatePods(projectPath)
    # archieve
    ipaPath = autoScript.buildProject(projectPath, projectName)
    print('打包结束')
    print('*'*10+' 开始上传 '+'*'*10)
    net = NetworkingClass()
    net.uploadIpaToPgy(ipaPath,apiKey)
    # net.uploadIpaToPgy('./ArchieveFiles/build/ShenTongScoringEdu.ipa', 'ca5ca74439688abb3de501fb77bf6d24')
    # pwd = os.getcwd()
    # print(pwd)

